﻿@model OrderConfirmModel

@{
    Layout = "~/Views/Shared/_ColumnsOne.cshtml";
    NopHtml.AddTitleParts(T("PageTitle.Checkout").Text);
}

<div class="page checkout-page order-confirm-page">
    <div class="page-title">
        <h1>@T("Checkout.ConfirmYourOrder")</h1>
    </div>
    <div class="page-body checkout-data">
        @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.CheckoutConfirmTop, additionalData = Model })
        <div class="section confirm-order">
            <form asp-controller="PayPalCommercePublic" asp-action="ConfirmOrderPost" method="post" id="confirm-order-form">
                <input asp-for="OrderId" type="hidden" />
                <input asp-for="OrderGuid" type="hidden" />
                <input asp-for="LiabilityShift" type="hidden" />
                <script asp-location="Footer">
                    $(function () {
                        $('#confirm-order-form').submit(function () {
                            $('input[type=submit]', this).attr('disabled', 'disabled');
                        });

                        $('.confirm-order-next-step-button').on('click', function () {
                            var termOfServiceOk = true;
                            if ($('#termsofservice').length > 0) {
                                if (!$('#termsofservice').is(':checked')) {
                                    $("#terms-of-service-warning-box").dialog();
                                    termOfServiceOk = false;
                                } else {
                                    termOfServiceOk = true;
                                }
                            }
                            if (termOfServiceOk) {
                                return true;
                            } else {
                                return false;
                            }
                        });
                    });
                </script>
                @if (!string.IsNullOrEmpty(Model.MinOrderTotalWarning))
                {
                    <span class="min-order-warning">@Model.MinOrderTotalWarning</span>
                }
                else
                {
                    if (Model.TermsOfServiceOnOrderConfirmPage)
                    {
                        <div id="terms-of-service-warning-box" title="@T("Checkout.TermsOfService")" style="display: none;">
                            <p>@T("Checkout.TermsOfService.PleaseAccept")</p>
                        </div>
                        <div class="terms-of-service">
                            <input id="termsofservice" type="checkbox" name="termsofservice" />
                            <label for="termsofservice">@T("Checkout.TermsOfService.IAccept")</label>
                            @if (Model.TermsOfServicePopup)
                            {
                                <a class="read" id="read-terms">@T("Checkout.TermsOfService.Read")</a>
                                <script asp-location="Footer">
                                    $(function () {
                                        $('#read-terms').on('click', function (e) {
                                            e.preventDefault();
                                            displayPopupContentFromUrl('@Url.RouteUrl("TopicPopup", new { SystemName = "conditionsofuse" })', '@T("Checkout.TermsOfService")');
                                        });
                                    });
                                </script>
                            }
                            else
                            {
                                <a class="read" id="read-terms" href="@Url.RouteTopicUrl("conditionsofuse")">@T("Checkout.TermsOfService.Read")</a>
                            }
                        </div>
                    }
                    <div class="buttons">
                        <button type="submit" name="nextstep" class="button-1 confirm-order-next-step-button">@T("Checkout.ConfirmButton")</button>
                    </div>
                    <script asp-location="Footer">
                        $('#confirm-order-form').on('submit', function () {
                            var button = $(this).find('button[type="submit"][name="nextstep"]');
                            setTimeout(function () {
                                button.prop('disabled', true);
                            }, 0);
                        });
                    </script>
                    if (Model.DisplayCaptcha)
                    {
                        <nop-captcha />
                    }
                }
                @if (Model.Warnings.Any())
                {
                    <div class="message-error">
                        <ul>
                            @foreach (var warning in Model.Warnings)
                            {
                                <li>@warning</li>
                            }
                        </ul>
                    </div>
                }
            </form>
        </div>
        @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.CheckoutConfirmBottom, additionalData = Model })
        <div class="section order-summary">
            @await Component.InvokeAsync(typeof(OrderSummaryViewComponent), new { prepareAndDisplayOrderReviewData = true })
        </div>
    </div>
</div>